package com.neusoft.neumooc.dao.front;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.neusoft.core.common.BaseDAO;
import com.neusoft.core.common.exception.DAOException;
import com.neusoft.neumooc.vo.MenuVO;

/**
 * @ClassName: MenuDAOImpl
 * @Description: TODO 菜单数据访问类
 * @author huangruijin
 * @date 2016年8月16日
 */
@Repository
public class MenuDAOImpl extends BaseDAO implements MenuDAO {

	
	// 获取一级导航列表
	private static final String SQL_GET_ONE_MENU_LIST = "select *,(select count(1) from cw_menus cm2 where cm2.parentId=cm.menuId) as childNum from cw_menus cm where parentId is null order by seq";

	/**
	 * @Title: getParentMenuList
	 * @Description: TODO 获取一级导航列表
	 * @return 一级导航列表
	 * @throws DAOException
	 */
	@Override
	public List<MenuVO> getOneMenuList() throws DAOException {

		try {
			return this.queryForBeanList(SQL_GET_ONE_MENU_LIST, MenuVO.class);
		} catch (Exception e) {
			throw new DAOException("class MenuDAOImpl-->method getOneMenuList error", e);
		}
	}

	// 获取二级导航列表
	private static final String SQL_GET_TWO_MENU_LIST = "select * from cw_menus where parentId is not null order by seq";

	/**
	 * @Title: getTwoMenuList
	 * @Description: TODO 获取二级导航列表
	 * @return 二级导航列表
	 * @throws DAOException
	 */
	@Override
	public List<MenuVO> getTwoMenuList() throws DAOException {

		try {
			return this.queryForBeanList(SQL_GET_TWO_MENU_LIST, MenuVO.class);
		} catch (Exception e) {
			throw new DAOException("class MenuDAOImpl-->method getTwoMenuList error", e);
		}
	}

	

}
